package com.ruoyi.recycle.mapper;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.toolkit.Constants;
import com.ruoyi.recycle.domain.RecycleOrder;
import com.ruoyi.recycle.dto.HomePageStatisticalOrderData;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.math.BigDecimal;
import java.util.Date;
import java.util.List;
import java.util.Map;

/**
 * 回收订单Mapper接口
 *
 * @author ruoyi
 * @date 2022-05-22
 */
public interface RecycleOrderMapper extends BaseMapper<RecycleOrder> {
    /**
     * 查询回收订单
     *
     * @param recycleOrderNo 回收订单主键
     * @return 回收订单
     */
    public RecycleOrder selectRecycleOrderById(String recycleOrderNo);

    /**
     * 查询回收订单列表
     *
     * @param recycleOrder 回收订单
     * @return 回收订单集合
     */
    public List<RecycleOrder> selectRecycleOrderList(RecycleOrder recycleOrder);

    /**
     * 新增回收订单
     *
     * @param recycleOrder 回收订单
     * @return 结果
     */
    public int insertRecycleOrder(RecycleOrder recycleOrder);

    /**
     * 修改回收订单
     *
     * @param recycleOrder 回收订单
     * @return 结果
     */
    public int updateRecycleOrder(RecycleOrder recycleOrder);

    /**
     * 删除回收订单
     *
     * @param recycleOrderNo 回收订单主键
     * @return 结果
     */
    public int deleteRecycleOrderById(String recycleOrderNo);

    /**
     * 批量删除回收订单
     *
     * @param recycleOrderNos 需要删除的数据主键集合
     * @return 结果
     */
    public int deleteRecycleOrderByIds(String[] recycleOrderNos);

    List<HomePageStatisticalOrderData> homePageStatisticalRecycleOrderData(@Param("stateTime") Date stateTime, @Param("type") String type);


    List<HomePageStatisticalOrderData> findByHourGroupByAdd(@Param("start") Date start, @Param("end") Date end);

    List<Map<String, String>> carbonReduction(@Param("clientId") Integer clientId);

    @Select("select sum(integral) from recycle_order ${ew.customSqlSegment}")
    BigDecimal sumFinishedOrder(@Param(Constants.WRAPPER) LambdaQueryWrapper<RecycleOrder> wrapper);


    Double carbonReductionSum(@Param("clientId") Long clientId);

    List<RecycleOrder> checkIsAvailableRecycle(@Param("clientId")Long clientId);
}
